package com.pyg.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pyg.goods.service.TbBrandService;
import com.pyg.pojo.TbBrand;

import entity.PageResult;
import entity.Result;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
*  @Author zhuliangcai
*  @Email 1024955966@qq.com
*  @Date 2017-10-16 08:35:14
*/
@RestController
@RequestMapping("/brand")
public class BrandController {
	
    @Reference
    private TbBrandService tbBrandService;
    
    @RequestMapping("/findAll")
    public List<TbBrand> findAll() {
        return tbBrandService.findAll();
    }
    @RequestMapping("/findPage")
    public PageResult findPage(int pageNum, int pageSize) {
        return tbBrandService.findPage(pageNum,pageSize);
    }
    @RequestMapping("/search")
    public PageResult search(@RequestBody TbBrand tbBrand, int pageNum, int pageSize) {
        return tbBrandService.findPage(tbBrand,pageNum,pageSize);
    }
    @RequestMapping("/add")
    public Result add(@RequestBody TbBrand tbBrand) {

        try {
            tbBrandService.add(tbBrand);
            return new Result(true,"添加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"添加失败");
        }
    }
    @RequestMapping("/del")
    public Result del(Long[] ids) {
        try {
            tbBrandService.del(ids);
            return new Result(true,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"删除失败");
        }
    }
    @RequestMapping("/findOne")
    public TbBrand findOne(Long id) {
        return tbBrandService.findOne(id);
    }
    @RequestMapping("/update")
    public Result update(@RequestBody TbBrand tbBrand) {

        try {
            tbBrandService.update(tbBrand);
            return new Result(true,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"修改失败");
        }
    }
//    @RequestMapping("/selectOptionList")
//    public List<Map> selectOptionList(){
//        return tbBrandService.selectOptionList();
//    }

}
